package com.kunbo.cn.app.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kunbo.cn.app.entity.NoticeOfArrival;
import com.kunbo.cn.app.service.NoticeOfArrivalService;
import com.kunbo.cn.util.retu.BuildBean;
import com.kunbo.cn.util.retu.ResultBean;

@RestController
@RequestMapping("/noticeOfArrival")
public class NoticeOfArrivalController {
	
	
	@Autowired
	private NoticeOfArrivalService service;
	
	
	@PostMapping("/saveArrival")
	public ResultBean<Boolean> saveArrival(
			@RequestParam("uuid")String uuid,
			@RequestParam("create_user_id")String create_user_id,
			@RequestParam("notification_type")String notification_type,
			@RequestParam("notification_code")String notification_code,
			@RequestParam("waybill_code")String waybill_code,
			@RequestParam("order_code")String order_code,
			@RequestParam("supplier")String supplier,
			@RequestParam("material_name")String material_name,
			@RequestParam("receiving_unit")String receiving_unit,
			@RequestParam("transport_unit")String transport_unit,
			@RequestParam("car_number")String car_number,
			@RequestParam("frid")String frid,
			@RequestParam("driver_name")String driver_name,
			@RequestParam("id_number")String id_number,
			@RequestParam("note")String note,
			@RequestParam("accruals")float accruals,
			@RequestParam("vehicle_authenticated_load")float vehicle_authenticated_load,
			@RequestParam("volume_to_be_transported")String volume_to_be_transported,
			@RequestParam("driver_phone")String driver_phone
			){
		ResultBean<Boolean> result = new ResultBean<Boolean>();
		return BuildBean.buildResult(result, "succes", "error", service.saveArrival(notification_type,notification_code,waybill_code,order_code,supplier,material_name,receiving_unit,transport_unit,car_number,frid,driver_name,id_number,note,accruals,vehicle_authenticated_load,uuid,create_user_id,volume_to_be_transported,driver_phone));
	}
	
	
	
	
	
	@PostMapping("/updArrival")
	public ResultBean<Boolean> updArrival(
			@RequestParam("id")Integer id,
			@RequestParam("notification_type")String notification_type,
			@RequestParam("notification_code")String notification_code,
			@RequestParam("waybill_code")String waybill_code,
			@RequestParam("order_code")String order_code,
			@RequestParam("supplier")String supplier,
			@RequestParam("material_name")String material_name,
			@RequestParam("receiving_unit")String receiving_unit,
			@RequestParam("transport_unit")String transport_unit,
			@RequestParam("car_number")String car_number,
			@RequestParam("frid")String frid,
			@RequestParam("driver_name")String driver_name,
			@RequestParam("id_number")String id_number,
			@RequestParam("note")String note,
			@RequestParam("accruals")float accruals,
			@RequestParam("vehicle_authenticated_load")float vehicle_authenticated_load,
			@RequestParam("old_net_weight")Double old_net_weight
			){
		ResultBean<Boolean> result = new ResultBean<Boolean>();
		return BuildBean.buildResult(result, "succes", "error", service.updArrival(id,notification_type,notification_code,waybill_code,order_code,supplier,material_name,receiving_unit,transport_unit,car_number,frid,driver_name,id_number,note,accruals,vehicle_authenticated_load,old_net_weight));
	}
	
	
	@PostMapping("/selArrival")
	public ResultBean<NoticeOfArrival> selArrival(
			@RequestParam("id")Integer id
			){
		ResultBean<NoticeOfArrival> result = new ResultBean<NoticeOfArrival>();
		return BuildBean.buildResult(result, "succes", "error", service.selArrival(id));
	}
	
	
	
	@PostMapping("/selAllArrival")
	public ResultBean<List<Map<String,Object>>> selAllArrival(
			@RequestParam("wayBillUnit")Integer wayBillUnit,
			@RequestParam("notificationNumber")String notificationNumber,
			@RequestParam("page")Integer page,
			@RequestParam("pageSize")Integer pageSize
			){
		ResultBean<List<Map<String,Object>>> result = new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "success", "error", service.selAllArrival(notificationNumber,page,pageSize,wayBillUnit));
	}
	
	
	

}
